package com.raven.play.stream.test.javadsl.tutorial;

import akka.actor.typed.DispatcherSelector;
import akka.actor.typed.Dispatchers;
import akka.stream.ActorAttributes;
import akka.stream.Attributes;
import akka.stream.javadsl.Sink;
import akka.stream.javadsl.Source;
import com.raven.play.stream.test.BaseTest;
import org.junit.jupiter.api.Test;
import scala.concurrent.ExecutionContextExecutor;

public class $07OperatorFusion extends BaseTest {

    @Test
    public void test(){
        // Attributes dispatcher = ActorAttributes.dispatcher("dedicated-dispatcher");
        // ExecutionContextExecutor executor = system.dispatchers().lookup(DispatcherSelector.fromConfig("dedicated-dispatcher"));
        Source.range(1, 10).async("my-custom-dispatcher")
                .map(element -> {
                    log.info("Flow A: {}", element);
                    return element;
                }).async()
                .map(element -> {
                    log.info("Flow B: {}", element);
                    return element;
                }).async()
                .map(element -> {
                    log.info("Flow C: {}", element);
                    return element;
                }).async()
                .to(Sink.ignore())
                .run(system);

    }
}
